package org.biubiu0002.baiblog.core.controller;

import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.biubiu0002.baiblog.common.utils.R;
import org.biubiu0002.baiblog.core.annotations.PermissionIgnore;
import org.biubiu0002.baiblog.core.model.vo.res.LoginResVo;
import org.biubiu0002.baiblog.core.service.OAuthService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: biubiu0002
 * @Date: 2022/11/1 11:28
 **/
@RestController
@RequestMapping("/oauth")
public class OAuthController {

    @Resource
    private OAuthService oAuthService;

    @GetMapping("/github")
    @PermissionIgnore
    public void getGithubCode(String code,String status){
    }

    @GetMapping("/gitee")
    @PermissionIgnore
    public R giteeLogin(String code, HttpServletResponse response) throws IOException {
        Preconditions.checkArgument(StringUtils.isNotBlank(code),"临时凭证code不能为空");
        LoginResVo loginResVo = oAuthService.giteeLogin(code);

        return R.ok().put("data",loginResVo);



    }



}
